package com.daily.daily_push.service;

import com.alibaba.fastjson.JSONObject;
import io.kubernetes.client.openapi.ApiClient;
import io.kubernetes.client.openapi.models.V1ConfigMap;
import io.kubernetes.client.openapi.models.V1Deployment;
import io.kubernetes.client.openapi.models.V1Namespace;
import io.kubernetes.client.openapi.models.V1Pod;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.util.List;
import java.util.Map;

public interface K8sApiService {

    /**
     * 查询pod列表
     *
     * @return List<V1Pod>
     */
    List<V1Pod> k8sGetPods(ApiClient client, String namespace, String pretty, Boolean allowWatchBookmarks, String _continue, String fieldSelector, String labelSelector, Integer limit, String resourceVersion, String resourceVersionMatch, Integer timeoutSeconds, Boolean watch);

    /**
     * 获取指定命名空间和 Pod的日志
     *
     * @return String
     */
    String getNamespacedPodLog(ApiClient client,String name, String namespace, String container, Boolean follow, Boolean insecureSkipTLSVerifyBackend, Integer limitBytes, String pretty, Boolean previous, Integer sinceSeconds, Integer tailLines, Boolean timestamps);

    /**
     * 通过参数创建pod
     *
     */
    V1Pod createNamespacePod(ApiClient client,String podName,String container,String image,Integer containerPort,String namespace,  String pretty, String dryRun, String fieldManager, String fieldValidation);

    /**
     * 通过deployment、yaml模式创建pod
     *
     */
    V1Deployment createDeploymentPod(ApiClient client,File yamlFile,String namespace, String pretty, String dryRun, String fieldManager, String fieldValidation);


    /**
     * 查询deployment，通过指定命名空间和pod名称
     *
     */
    List<V1Deployment> listNamespacedDeployment(ApiClient client,String namespace, String pretty, Boolean allowWatchBookmarks, String _continue, String fieldSelector, String labelSelector, Integer limit, String resourceVersion, String resourceVersionMatch, Integer timeoutSeconds, Boolean watch);

    /**
     * 查询k8s集群信息
     *
     */
    Map<String,Object> k8sInfo(ApiClient client);

    /**
     * 查询k8s命名空间列表信息
     *
     */
    List<V1Namespace> listNamespace (ApiClient client);

    /**
     * 查询k8s命名空间下的configMap
     *
     */
    V1ConfigMap listConfigMap (ApiClient client,String namespace, String configMapName);

    /**
     * 查询k8s命名空间下的configMap
     *
     */
    Map listSecret (ApiClient client,String namespace, String secretName);

}


